package cn.edu.cqupt.Tools;


//工具类
public class UtilFactory {
	
	

	public static int fun1(int data[]){
		if(data[1]==0){
			data[2]=1;
			data[4]=0;
			return data[0];
		}
		int temp=data[1];
		data[1]=data[0]%data[1];
		data[0]=temp;
		int ans=fun1(data);
		int temp1=data[2];
		data[2]=data[3];
		data[3]=temp-data[0]/data[1]*data[3];
		return ans;
		
	}
	//计算a*x%b=1时x的值
	public static int cal(int a,int b,int c){
		int x=0,y=0;
		int data[]={a,b,x,y};
		int gcd=fun1(data);
		if ((c%gcd)!=0) return -1;
		data[2]*=c/gcd;
		b/=gcd;
		if (b<0);
		b=-b;
		int ans=data[2]%b;
		if (ans<=0) 
			ans+=b;
		return ans;
	}
	
	//计算a*b*c的值
	public static int fun2(int a,int b,int c){
		int res= 1;
		while(b!=0){
			if ((b&1)==1){
				res=res*a%c;
				--b;
			}
			else{
				a=a*a%c;
				b>>=1;
			}
		}
		return  res;
	}
	
	public static void main(String[] args) {
		long t=15;
		
		if ((5&1)==1){
			System.out.println("是奇数");
		}
		else {
			System.out.println("不是奇数");
		}
		int a=3;
		int b=2147483647;
		int c=1000;
		
		//System.out.println("res:"+fun2(a, b, c));
		System.out.println("x="+cal(3, 11, 1));
		
		
	}
	
	
	

}
